<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('训练成绩录入')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="data-form">
                <input id="teacherId" name="teacherId"  th:value="*{teacherId}" hidden="true">
                <div class="select-list">
                    <ul>
                        <li>
                            <label style="margin-right: 15px">上课时间: </label>
                            <div class="input-group date">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                <input id="scheduleTime" name="scheduleTime" type="text" class="col-sm-3 control-label" placeholder="yyyy-MM-dd">
                                <label style="width: 25px"></label>
                                <label shiro:hasPermission="education:schedule:searchTeacher">老师姓名：</label>
                                <input shiro:hasPermission="education:schedule:searchTeacher" id="teacherName" type="text" class="col-sm-3 control-label '+searchTeacherFlag+'" name="teacherName" />
<!--                                <label style="width: 25px"></label>-->
<!--                                <label>学生姓名：</label>-->
<!--                                <input id="childName" type="text" class="col-sm-3 control-label" name="childName" />-->
                                <label style="width: 25px"></label>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            </div>
                        </li>
                    </ul>
                </div>
            </form>

        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-auto-refresh-silent="true" data-auto-refresh ="false" data-auto-refresh-interval="5" ></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-table-auto-refresh-js" />
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    // 权限
    var enteringFlag = [[${@permission.hasPermi('education:studentEntering:view')}]];
    var prefix = ctx + "education/childScheduleRecord";

    $(function () {
        layui.use('laydate', function () {
            layui.laydate.render({
                elem: '#scheduleTime',
                value: new Date(),
                format: 'yyyy-MM-dd',
                type: 'date'
            });
        })
    });

    $(function () {
        var options = {
            url: prefix + "/list",
            queryParams: queryParams,
            modalName: "数据",
            columns: [
                {
                    field: 'courseTime',
                    title: '上课时间',
                },
                {
                    field: 'courseName',
                    title: '课程名称',
                },
                {
                    field: 'teacherName',
                    title: '老师姓名',
                },
                {
                    field: 'children',
                    title: '学员姓名',
                },
                {
                    field: 'signType',
                    title: '签到状态',
                    align: "center",
                    formatter: function (value, row, index) {
                        var actions = [];
                        if ($.common.isNotEmpty(value)) {
                            if(value == '0'){
                                actions.push($.common.sprintf("<span class='%s'>%s</span>", "default","取消签到"));
                            }
                            if(value == '1'){
                                actions.push($.common.sprintf("<span class='%s'>%s</span>", "default","已签到"));
                            }
                            if(value == '2'){
                                actions.push($.common.sprintf("<span class='%s'>%s</span>", "default","请假"));
                            }
                            if(value == '3'){
                                actions.push($.common.sprintf("<span class='%s'>%s</span>", "default","旷课"));
                            }
                            if(value == '4'){
                                actions.push($.common.sprintf("<span class='%s'>%s</span>", "default","补课"));
                            }
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'updateBy',
                    title: '最后编辑人',
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if(row.isShowEdit == 1) {
                            actions.push('<a class="btn btn-success btn-xs ' + enteringFlag + '" href="javascript:void(0)" onclick="studentEntering(\'' + row.id + "," + row.projectType + '\')"><i class="fa fa-edit"></i>成绩录入</a>');
                        }
                        actions.push('<label style="width: 10px"></label>');
                        if(row.isCurDay == 1) {
                            if(row.isHaveData ==1) {
                                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="studentEnteringShow(\'' + row.id + ",1" + '\')"><i class="fa fa-edit"></i>查看上次成绩</a>');
                            }
                            else {
                                actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)"><i class="fa fa-edit"></i>查看上次成绩</a>');
                            }
                        }
                        else {
                            if(row.isHaveData ==1) {
                                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="studentEnteringShow(\'' + row.id + ",0" +'\')"><i class="fa fa-edit"></i>查看成绩</a>');
                            }
                            else {
                                actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)"><i class="fa fa-edit"></i>查看成绩</a>');
                            }
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function studentEntering(data) {
        var arr = data.split(",");
        var url = prefix + "/studentEntering/"+arr[0];
        $.modal.openTab("录入", url);
    }

    function studentEnteringShow(data) {
        var arr = data.split(",");
        var url = prefix + "/studentEnteringShow/"+arr[0]+"/"+arr[1];
        $.modal.openTab("查看", url);
    }

    function queryParams(params) {
        var search = $.table.queryParams(params);
        var selectIndex = window.parent.document.getElementById('parentSchoolList').selectedIndex;
        if (selectIndex >= 0) {
            var centerId = window.parent.document.getElementById('parentSchoolList').options[selectIndex].value;
            search.centerId = centerId;
        }
        var scheduleTime = $('#scheduleTime').val();
        var teacherId = $('#teacherId').val();
        search.scheduleTime =scheduleTime;
        search.teacherId =teacherId;
        return search;
    }
</script>
</body>

</html>